package util.list;

import util.tree.TreeNode;

public class ListNode {
    public int val;
    public ListNode next;

    public ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }

    public ListNode(int val) {
        this.val = val;
        this.next = null;
    }

    @Override
    public String toString() {
        String s = String.valueOf(val);
        if (next == null)
            return s;
        else {
            return s + " -> " + next.toString();
        }
    }
}
